	<div class="tabbable"> 
	  <ul class="nav nav-tabs">
	    <li class="active"><a href="#tab10" data-toggle="tab"><?echo __("Generale")?></a></li>
	    <li><a href="#tab15" data-toggle="tab"><?echo __("Profilatura")?></a></li>
	    <li><a href="#tab20" data-toggle="tab"><?echo __("Log")?></a></li>
	    <li><a href="#tab30" data-toggle="tab"><?echo __("Phpinfo")?></a></li>
	    <li><a href="#tab40" data-toggle="tab"><?echo __("Query")?></a></li>
	  </ul>
	  <div class="tab-content">
	    <div class="tab-pane active" id="tab10">
			<fieldset>
				<label><?php echo __('Utente') . ': ' . $this->Session->read("Auth.User.username"); ?></label>
				<label><?php echo __('Sessione') . ': ' . session_id(); ?></label>
				<label><?php echo __('Lingua') . ': ' . Configure::read("Config.language"); ?></label>
				<label><?php echo __('Web Root') . ': ' . $this->webroot; ?></label>
				<label><?php echo __('Database') . ': ' . $database; ?></label>
				<label><?php echo __('Elenco Database') . ": "; ?>
					<?php 
						foreach ($databases as $dbname => $db) {
							echo " ".$dbname ." (". $db["host"] ." - ". $db["database"] .")";
						}
					?>
				</label>
				<label><?php echo __('Memoria disponibile') . ': ' . ini_get('memory_limit'); ?></label>
				<label><?php echo __('Memoria utilizzata') . ': ' . intval(memory_get_usage()/1024/1024) . "MB (" . memory_get_usage() . ")"; ?></label>
			</fieldset>
	    </div>
	    
	    <div class="tab-pane" id="tab15">
				<p> <a href='<?php echo $this->webroot;?>Info/refreshPermission' class="btn" ><?echo __("Aggiorna permessi")?> <i class='icon-refresh'></i></a></p>
				<p>	
					<table id="table_permission" cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered">
					    <thead>
					        <tr>
					            <th><?echo __("Aco")?></th>
					            <th><?echo __("Valore")?></th>
					        </tr>
					    </thead>
					    <tbody>
							<?php foreach ($this->Session->read("permissions") as $permission => $value) { ?>
						        <tr>
						            <td><?php echo $permission ?></td>
						            <td><?php echo $value ?></td>
						        </tr>
							<?php } ?>
					    </tbody>
					</table>				
				</p>
	    </div>
	    
	    <div class="tab-pane" id="tab20">

			<p>
				<a href='<?php echo $this->webroot;?>Info/downloadLog/debug' class="btn" ><?echo __("Download file")?> debug.log <i class='icon-download'></i></a>
				<a href='<?php echo $this->webroot;?>Info/downloadLog/error' class="btn" ><?echo __("Download file")?> error.log <i class='icon-download'></i></a>
				<a href='<?php echo $this->webroot;?>Info/downloadLog/emailcronshell' class="btn" ><?echo __("Download file")?> emailcronshell.log <i class='icon-download'></i></a>
				<a href='<?php echo $this->webroot;?>Info/downloadLog/prestazionecronshell' class="btn" ><?echo __("Download file")?> prestazionecronshell.log <i class='icon-download'></i></a>
			</p>

				
				<table id="table_log" cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered">
				    <thead>
				        <tr>
				            <th><?echo __("Id")?></th>
				            <th><?echo __("Livello")?></th>
				            <th><?echo __("Sessione")?></th>
				            <th><?echo __("Ip")?></th>
				            <th><?echo __("Messaggio")?></th>
				            <th><?echo __("Data")?></th>
				        </tr>
				    </thead>
				    <tbody>
				        <tr>
				            <td><?php echo $log['Log']['id'] ?></td>
				            <td><?php echo $log['Log']['level'] ?></td>
				            <td><?php echo $log['Log']['session'] ?></td>
				            <td><?php echo $log['Log']['ip'] ?></td>
				            <td><?php echo $log['Log']['message'] ?></td>
				            <td><?php echo $log['Log']['dt_ins'] ?></td>
				        </tr>
				    </tbody>
				</table>				
	    </div>
	    <div class="tab-pane" id="tab30">

	    </div>
	    <div class="tab-pane" id="tab40">

			<div class="tabbable"> 
			  <ul class="nav nav-tabs">
			    <li class="active"><a href="#tabQuerySql" data-toggle="tab"><?echo __("Sql")?></a></li>
			    <li><a href="#tabQueryModel" data-toggle="tab"><?echo __("Model")?></a></li>
			  </ul>
			  <div class="tab-content">
			    <div class="tab-pane active" id="tabQuerySql">
			    	<form action="<?php echo $this->webroot;?>Info/eseguiQuerySql" method="post" id="formQuery">
						<textarea id='query' name="query" rows="10" class="span12" ></textarea>
			    		<?php if ($this->Permission->check("controllers/info/eseguiQuerySql")) { ?>
							<button type="submit" class="btn btn-primary pull-right"><i class='icon-search'></i></button>
						<?php } ?>
					</form>
					<table class="table" id="result"  >
					</table>			
				</div>
			    <div class="tab-pane" id="tabQueryModel">
			    	<form action="<?php echo $this->webroot;?>Info/eseguiQueryModel" method="post" id="formQueryModel">
			    		<input id="model" name="model" placeholder="Model"/>
			    		<input id="idModel" name="idModel" placeholder="Id"/>
			    		<input id="recursive" name="recursive" placeholder="Recursive" value="0"/>
			    		<?php if ($this->Permission->check("controllers/info/eseguiQueryModel")) { ?>
							<button type="submit" class="btn btn-primary pull-right"><i class='icon-search'></i></button>
						<?php } ?>
					</form>
					<span  id="resultQueryModel"  >
					</span>			
				</div>
			  </div>
			</div>
			
				
	    </div>
	  </div>
	</div>

<script>



	$(document).ready(function() {
		
		$('#table_permission').dataTable({
		"sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>"
		});
		
		$('#table_log').dataTable({
			"sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
			"oLanguage": {
			"sLengthMenu": "      _MENU_ records per page",
			"sZeroRecords": "Nothing found - sorry",
			"sInfo": "Showing _START_ to _END_ of _TOTAL_ records",
			"sInfoEmpty": "Showing 0 to 0 of 0 records",
			"sInfoFiltered": "(filtered from _MAX_ total records)"}
			,"bProcessing": true,"bServerSide": true,
			"sAjaxSource": "<?php echo $this->webroot;?>Info/getLog"
			});
			
			
		 $("#formQuery").submit(function(event) {
		 	if($("#query").val()=="")return;
			event.preventDefault();
			//invia la query in POST
			data= $("#formQuery").serialize();
			action= $("#formQuery").attr("action");
			var jqxhr = $.post(action,data, function(data) {
			  dataTable = jsonToTable(data);
			  setFlash($("#query").val());
			  $("#result").html(dataTable);
			},'json')
			.done(function(data) {  })
			.fail(function(xhr, textStatus, errorThrown) {
			  		setFlash(xhr.responseText,'error');
			    })
			.always(function() { });
		 });

		 $("#formQueryModel").submit(function(event) {
		 	if($("#model").val()=="" || $("#idModel").val()=="")return;
			event.preventDefault();
			//invia la query in POST
			data= $("#formQueryModel").serialize();
			action= $("#formQueryModel").attr("action");
			var jqxhr = $.post(action,data, function(data) {
			  setFlash("Ricerca eseguita.");
			  $("#resultQueryModel").html(data);
			},'text')
			.done(function(data) {  })
			.fail(function(xhr, textStatus, errorThrown) {
			  		setFlash(xhr.responseText,'error');
			    })
			.always(function() { });
		 });

	} );
	
	$.extend( $.fn.dataTableExt.oStdClasses, {
    	"sWrapper": "dataTables_wrapper form-inline"
	} );
	
	/* API method to get paging information */
	$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
	{
		return {
			"iStart": oSettings._iDisplayStart,
			"iEnd": oSettings.fnDisplayEnd(),
			"iLength": oSettings._iDisplayLength,
			"iTotal": oSettings.fnRecordsTotal(),
			"iFilteredTotal": oSettings.fnRecordsDisplay(),
			"iPage": oSettings._iDisplayLength === -1 ?
			0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
			"iTotalPages": oSettings._iDisplayLength === -1 ?
			0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
		};
	}; 

</script>
				